/*
 * @Author: your name
 * @Date: 2021-10-14 14:00:19
 * @LastEditTime: 2021-10-14 16:03:26
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \Alive-master\assets\script\game\showTime.ts
 */
const { ccclass, property } = cc._decorator;

@ccclass
export default class ShowTime extends cc.Component {
	/**文本 */
	_label: cc.Label | undefined = undefined;
	/**显示时间 */
	_show: number = 3;
	/**时间 */
	_time: number = 0;

	onLoad(): void {
		this._label = this.node.getComponent(cc.Label);
	}

	update(dt): void {
		this._time += dt;
		if (this._time < 1) return;

		this._show--;
		this._time = 0;

		if (this._show < -1) return;

		if (this._show > 0) {
			this._label.string = this._show + '';
		} else if (this._show === 0) {
			this._label.string = 'Go';
		} else if (this._show === -1) {
			this._label.string = '';
		}
	}
}
